package com.sunzm.dynamic_rule.functions;

import org.apache.flink.api.common.serialization.SimpleStringSchema;
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer;
import org.apache.kafka.clients.consumer.ConsumerConfig;

import java.util.Properties;

/**
 * souce类函数封装
 *
 * @author Administrator
 * @version 1.0
 * @date 2021-07-07 0:58
 */
public class SourceFunctions {
    public static FlinkKafkaConsumer<String> getKafkaEventSource(){

        Properties properties = new Properties();
        properties.setProperty(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "82.156.210.70:9093");
        properties.setProperty(ConsumerConfig.GROUP_ID_CONFIG, "flink-rule");
        //从最新的偏移量开始消费
        properties.setProperty(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "latest");
        FlinkKafkaConsumer<String> source = new FlinkKafkaConsumer<>("applog", new SimpleStringSchema(), properties);


        return source;
    }


    public static FlinkKafkaConsumer<String> getKafkaRuleSource() {


        //kafka数据源
        Properties properties = new Properties();
        properties.setProperty(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "82.156.210.70:9093");
        properties.setProperty(ConsumerConfig.GROUP_ID_CONFIG, "flink-rule");
        //从最新的偏移量开始消费
        properties.setProperty(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "latest");
        FlinkKafkaConsumer<String> source = new FlinkKafkaConsumer<>("canal_rule", new SimpleStringSchema(), properties);


        return source;
    }
}
